/* Helsinki University of Technology
 * T-106.530 Embedded Systems
 *
 * Car-project
 *
 * Target: Atmel AVR ATmega32
 *
 * Author: Petri Hintukainen, 44020U
 * Date:   2012/03/16
 */

#include "hal.h"

void blink(void)
{
  int n;
  car_set_led(1);
  for(n = 0; n < 4; n++) {
    sleep_ms(500);
    car_toggle_led();
  }
}

int main(void) {

  car_reset();
  blink();

  car_init();
  car_wait_button_pressed();

  lcd_string("testi...");
  car_set_speed(10);
  car_wait_button_pressed();

  car_init();

  while (1) {

    car_toggle_led();
    car_wait_button_pressed();

    car_toggle_led();
    car_wait_button_pressed();

    car_toggle_led();
    car_set_direction(-120);
    car_wait_button_pressed();

    car_toggle_led();
    car_set_direction(-40);
    car_wait_button_pressed();

    car_toggle_led();
    car_set_direction(0);
    car_wait_button_pressed();

    car_toggle_led();
    car_set_direction(40);
    car_wait_button_pressed();

    car_toggle_led();
    car_set_direction(120);
    car_wait_button_pressed();

    car_reset();
  }

  return 0;
} 

